package com.woupla.account;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.New;
import javax.inject.Inject;
import javax.inject.Named;

import org.jboss.solder.logging.Logger;

import com.woupla.company.CompanyController;
import com.woupla.model.User;


/**
 * 
 */

/**
 * @author Dimitri Lebel
 *
 */
@Named
@SessionScoped
public class UserMBean implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 4445950074774092185L;
	@Inject
	private UserEJB userEJB;
	@New
	private User user ;
	private List<User> users;
	@Inject 
	private CompanyController companyMBean;
	@Inject
	private Logger log;
	@Inject
	private CurrentUserManager currentUserManager;
	
	public void updateUser(){
		userEJB.updateUser(user);
	}
	@PostConstruct
	public void init(){
		user = currentUserManager.getCurrentAccount();
	}
	
	/**
	 * @return the user
	 */
	public User getUser() {
		return user;
	}
	/**
	 * @param user the user to set
	 */
	public void setUser(User user) {
		this.user = user;
	}
	
	/**
	 * @return the users
	 */
	public List<User> getUsers() {
		users = userEJB.getAllUsers();
		return users;
	}
	/**
	 * @param users the users to set
	 */
	public void setUsers(List<User> users) {
		this.users = users;
	}
	
	/**
	 * @return the companyMBean
	 */
	public CompanyController getCompanyMBean() {
		return companyMBean;
	}
	/**
	 * @param companyMBean the companyMBean to set
	 */
	public void setCompanyMBean(CompanyController companyMBean) {
		this.companyMBean = companyMBean;
	}
	public UserMBean() {
	}
	
	
	public void connectUser(){
		userEJB.findUser(user);
	}


	
}
